package com.my.screenadapter.mService;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import androidx.annotation.Nullable;
import android.util.Log;

import com.my.screenadapter.MyApplication;
import com.my.screenadapter.TestSingleInstance;
import com.my.screenadapter.utils.BundleUtils;

import cn.jpush.android.service.DaemonService$MyBinder;

/**
 * Created by zhangyingjie on 2019-10-24
 *
 * @function
 */
public class MyService extends Service {
    private final String TAG = "MyService"+this.hashCode();

    @Override
    public void onCreate() {
        super.onCreate();
        Thread thread = Thread.currentThread();
        Log.i(TAG, "onCreate: thread name:"+thread.getName()+" threadid:"+thread.getId()+"  pid: "+android.os.Process.myPid());
        TestSingleInstance instance = TestSingleInstance.getInstance();
        Log.i(TAG, "onCreate: instance "+instance.hashCode());

        Log.i(TAG, "onCreate: application instance "+ MyApplication.getInstance().hashCode());
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        Log.i(TAG, "onBind: ");
        BundleUtils.print(intent.getExtras());
        return new MyBinder();
    }

    private class MyBinder extends Binder{

    }

    @Override
    public void onRebind(Intent intent) {
        super.onRebind(intent);
        Log.i(TAG, "onRebind: ");
        BundleUtils.print(intent.getExtras());
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.i(TAG, "onStartCommand: ");
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onStart(Intent intent, int startId) {
        super.onStart(intent, startId);
        Log.i(TAG, "onStart: ");
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.i(TAG, "onUnbind: ");
        return super.onUnbind(intent);
    }
}
